home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / WIN_PRO / DS-1.ZIP;1 / RTT.ZIP / RTTMISC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-10  |  1.2 KB  |  64 lines

  1. #include "rtt.h"
  2.  
  3. int n_tmp_str  = 0;
  4. int n_tmp_cset = 0;
  5. struct sym_entry *params = NULL;
  6.  
  7. /*
  8.  * clr_def - clear any information related to definitions.
  9.  */
  10. novalue clr_def()
  11.    {
  12.    struct sym_entry *sym;
  13.  
  14.    n_tmp_str = 0;
  15.    n_tmp_cset = 0;
  16.    while (params != NULL) {
  17.       sym = params;
  18.       params = params->u.param_info.next;
  19.       free_sym(sym);
  20.       }
  21.    free_tend();
  22.    if (v_len != NULL)
  23.       free_sym(v_len);
  24.    v_len = NULL;
  25.    il_indx = 0;
  26.    lbl_num = 0;
  27.    abs_ret = SomeType;
  28.    }
  29.  
  30. /*
  31.  * ttol - convert a token representing an integer constant into a long
  32.  *  integer value.
  33.  */
  34. long ttol(t)
  35. struct token *t;
  36. {
  37.    register long i;
  38.    register char *s;
  39.    int base;
  40.  
  41.    s = t->image;
  42.    i = 0;
  43.    base = 10;
  44.  
  45.    if (*s == '0') {
  46.       base = 8;
  47.       ++s;
  48.       if (*s == 'x') {
  49.          base = 16;
  50.          ++s;
  51.          }
  52.       }
  53.    while (*s != '\0') {
  54.       i *= base;
  55.       if (*s >= '0' && *s <= '9')
  56.          i += *s++ - '0';
  57.       else if (*s >= 'a' && *s <= 'f')
  58.          i += *s++ - 'a' + 10;
  59.       else if (*s >= 'A' && *s <= 'F')
  60.          i += *s++ - 'A' + 10;
  61.       }
  62.    return i;
  63.    }
  64.